package com.lss.practice;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lss
 * @description
 * @createDate 2024/12/16-23:13
 * @tag
 */
public class Test {
    public static void main(String[] args) {

    }
    public static int[] twosum(int[] nums,int tar){
        Map<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            if (!map.containsKey(tar - nums[i])){
                map.put(nums[i],i);
            }else {
                return new int[]{map.get(tar - nums[i]),i};
            }

        }
        return null;
    }
}
